package com.yztctech.a24_03_orderedbroacast;

import android.content.Intent;
import android.content.IntentFilter;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

/**
 * 有序广播接收器:都是静态注册
 * 1、发送有序广播sendOrderedBroadcast
 * 2、创建自定义的BroadCastReceiver
 * 3、注册，加上优先级的属性
 * 4、数据下发和接收
 *      setResultXXXX ,getResultXXX ;@see MyReceiver2
 * 5、拦截广播
 *     abortBroadcast;@see MyReceiver3
 */
public class MainActivity extends AppCompatActivity {

    private Button sendBtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        sendBtn = (Button) findViewById(R.id.btn_send);
        sendBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //发送有序广播
                Intent intent = new Intent(MyConstants.ACTION_OREDER);
                //参数1=目的，参数2=权限------>字符串;权限越高优先级越高
                sendOrderedBroadcast(intent, null);
            }
        });

    }

}
